/*
 * @Description:
 * @Author: wangyan
 * @Date: 2021-03-02 11:11:19
 * @LastEditTime: 2021-03-24 15:01:03
 * @LastEditors: @yzcheng
 */
import {
  pageTodoList,
  startTask,
  delegateTask,
  trunTask,
  backTask,
  backFirstTask,
  overTask,
  saveCopiesData
} from '@/api/todoListApi.js'

export default {
  namespaced: true,
  state: () => ({}),
  getter: {},
  actions: {
    async pageTodoList(context, payload) {
      const rst = await pageTodoList(payload.pageOption, payload.data)
      if (rst.data.success) {
        return rst.data.data
      } else {
        return false
      }
    },
    async startTask(context, payload) {
      let rst = await startTask(payload)
      rst = rst.data
      if (rst.success) {
          return rst.data;
      } else {
          return false
      }
    },
    async delegateTask(context, payload) {
      let rst = await delegateTask(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    },
    async trunTask(context, payload) {
      let rst = await trunTask(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    },
    async backTask(context, payload) {
      let rst = await backTask(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    },
    async backFirstTask(context, payload) {
      let rst = await backFirstTask(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    },
    async overTask(context, payload) {
      let rst = await overTask(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    },
    async saveCopies(context, payload){
      let rst = await saveCopiesData(payload)
      rst = rst.data
      if (rst.success) {
        return rst.code
      } else {
        return false
      }
    }
  },
  mutations: {},
}
